/*
 * Svr_log.h
 *
 *  Created on: 2012-8-27
 *      Author: ThinkPad
 */

#ifndef SVR_LOG_H_
#define SVR_LOG_H_

#include "smart_lock.h"

#ifdef _DEBUG
#undef NODEBUG
#endif

class Svr_log
{
public:
  Svr_log();
  ~Svr_log();

public:
    void init(const char * log_file_name);
    void set_loglvl(int loglvl);
    void log_fmt(int nloglvl,const char * lpszFormat, ...);
    void log_fmt_arglist(int nloglvl,const char * lpszFormat,va_list argList);
    void log_save_db(int nloglvl,const char * lpszFormat, ...);
    void log_vod_fmt(int nloglvl,const char * lpszFormat, ...);
    void log_fmt_stream_arglist(int nloglvl,const char * lpszFormat,va_list argList);
private:
    bool is_exist_logdir(const char* log_dir);
    void log_str(const char * lpszFormat,const char * logtype);
private:
    int m_loglvl;
    char m_log_path[FILE_MAX_PATH];
    smart_lock msg_lock;
    char m_szMsg[8192];
    char m_filename[FILE_MAX_PATH];
};

#endif /* SVR_LOG_H_ */
